import axios from 'axios';
import {API_NEW_VERSION} from '../api';
var qs = require('qs');

const FREIGHT_APPOINTS = API_NEW_VERSION + 'freight_appoints';
const FREIGHT_APPOINT = API_NEW_VERSION + 'freight_appoint';
const FREIGHT_APPOINT_BY_ID = FREIGHT_APPOINT + '/by/';
const FREIGHT_APPOINT_UPDATE_STATUS = FREIGHT_APPOINT + '/update_status';
const FREIGHT_APPOINT_DISCOUNTS = API_NEW_VERSION + 'freight_appoint_discounts';
const FREIGHT_APPOINT_DISCOUNT_UPDATE_STATUS = API_NEW_VERSION + '/freight_appoint_discount/update_status';
const FREIGHT_APPOINT_DISCOUNT = API_NEW_VERSION + 'freight_appoint_discount';
const FREIGHT_APPOINT_DISCOUNT_DELETE = API_NEW_VERSION + 'freight_appoint_discount/delete/';
const FREIGHT_APPOINT_DISCOUNT_BY_ID = FREIGHT_APPOINT_DISCOUNT + '/by/';
const FREIGHT_APPOINT_ROUTE = API_NEW_VERSION + 'freight_appoint_route';
const FREIGHT_APPOINT_ROUTES = API_NEW_VERSION + 'freight_appoint_routes';
const FREIGHT_APPOINT_ROUTE_DELETE = API_NEW_VERSION + 'freight_appoint_route/delete/';
const FREIGHT_APPOINT_ROUTE_BY_ID = FREIGHT_APPOINT_ROUTE + '/by/';
const FREIGHT_APPOINT_DELETE = API_NEW_VERSION + 'freight_appoint/delete/';

export const searchFreightAppoints = params => {
  return axios.get(FREIGHT_APPOINTS, {params: params});
};

export const saveOrUpdateFreightAppoint = (params) => {
  return axios.post(FREIGHT_APPOINT, params);
};

export const getFreightAppoint = (id) => {
  return axios.get(FREIGHT_APPOINT_BY_ID + id);
};

export const updateFreightAppointStatus = (params) => {
  return axios.post(FREIGHT_APPOINT_UPDATE_STATUS, qs.stringify(params));
};

export const searchFreightAppointDiscounts = (params) => {
  return axios.get(FREIGHT_APPOINT_DISCOUNTS, {params: params});
};

export const updateFaDetailStatus = (params) => {
  return axios.post(FREIGHT_APPOINT_DISCOUNT_UPDATE_STATUS, qs.stringify(params));
};

export const saveOrUpdateFreightAppointDiscount = (params) => {
  return axios.post(FREIGHT_APPOINT_DISCOUNT, params);
};

export const delFreightAppointDiscount = (id) => {
  return axios.get(FREIGHT_APPOINT_DISCOUNT_DELETE + id);
};

export const getFreightAppointDiscount = (id) => {
  return axios.get(FREIGHT_APPOINT_DISCOUNT_BY_ID + id);
};

export const saveOrUpdateFreightAppointRoute = (params) => {
  return axios.post(FREIGHT_APPOINT_ROUTE, params);
};

export const delFreightAppointRoute = (id) => {
  return axios.get(FREIGHT_APPOINT_ROUTE_DELETE + id);
};

export const getFreightAppointRoute = (id) => {
  return axios.get(FREIGHT_APPOINT_ROUTE_BY_ID + id);
};

export const delFreightAppoint = (id) => {
  return axios.get(FREIGHT_APPOINT_DELETE + id);
};

export const searchFreightAppointDetail = params => {
  return axios.get(FREIGHT_APPOINT_DISCOUNTS, {params: params});
};

export const searchFreightAppointRoute = (params) => {
  return axios.get(FREIGHT_APPOINT_ROUTES, {params: params});
};
